/* eslint-disable no-unused-vars */
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui'
import './css/global.css'
import 'element-ui/lib/theme-chalk/index.css'
import http_utils from './vueRef/http_utils'
import VueCookie from 'vue-cookie'
import moment from 'moment'
import ECharts from 'vue-echarts'
// 引入条形图
import 'echarts/lib/chart/line'
// 引入饼图
import 'echarts/src/chart/pie'
// 引入柱状图
import  'echarts/lib/chart/bar';
// 引入提示框和标题组件
import 'echarts/lib/component/tooltip'
import 'echarts/lib/component/title';
import 'echarts';
Vue.component('v-chart', ECharts);

Vue.filter('dateformat', function(dataStr, pattern = 'YYYY-MM-DD HH:mm:ss') {
    return moment(dataStr).format(pattern)

})

Vue.prototype.$moment = moment
Vue.prototype.$request = http_utils
Vue.use(VueCookie)
Vue.use(ElementUI)

import VueRegister from './vueRef/vue-register'
Vue.use(VueRegister);


Vue.prototype.sizeFormat = function (value) {
    var sizeIdx = 0;
    var calcSize = value;
    while(calcSize > 1024) {
        calcSize /= 1024;
        sizeIdx ++;
        if(sizeIdx >= 3) {
            break;
        }
    }
    switch (sizeIdx) {
        case 0:
            return calcSize.toFixed(1) + "B";
        case 1:
            return calcSize.toFixed(1) + "KB";
        case 2:
            return calcSize.toFixed(1) + "MB";
        default:
            return calcSize.toFixed(1) + "GB";
    }
}

Date.prototype.format = function (formatStr) {
    var str = formatStr;
    var Week = ['日', '一', '二', '三', '四', '五', '六'];
    str = str.replace(/yyyy|YYYY/, this.getFullYear());
    str = str.replace(/MM/, (this.getMonth() + 1) > 9 ? (this.getMonth() + 1).toString() : '0' + (this.getMonth() + 1));
    str = str.replace(/dd|DD/, this.getDate() > 9 ? this.getDate().toString() : '0' + this.getDate());
    return str;
}

Vue.config.productionTip = false

new Vue({
    router,
    render: h => h(App)
}).$mount("#app")